package _12ProxyDesign.DynamicProxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class AdminProxy implements InvocationHandler{
    private Admin admin;
    public  AdminProxy(Admin admin){
        this.admin=admin;
    }
    /**
     *
     * @param proxy  被代理的对象
     * @param method    被代理对象的方法
     * @param args  方法的参数
     * @return
     * @throws Throwable
     */
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("start Dynamic Proxy");
        Object invoke = method.invoke(admin, args);
        System.out.println("end Dynamic Proxy");
        return invoke;
    }
}
